luci-app-snmpd: add SNMPv3 tab
authorChristian Korber <[email protected]>
Mon, 29 Jul 2024 11:39:46 +0000 (13:39 +0200)
committerPaul Donald <[email protected]>
Wed, 3 Sep 2025 18:55:05 +0000 (20:55 +0200)
This commit introduces a new tab with SNMPv3 options to set.
Authentication and encryption parameters can be set needed for
net-snmp's snmpd.conf in /var/run.

Signed-off-by: Christian Korber <[email protected]>
applications/luci-app-snmpd/htdocs/luci-static/resources/view/snmpd/snmpd.js

index cc6c9492dc494d32ab1a397fa33e693fff10408c..858a9056d6efee6d15c86c2046986b7da0be0950 100644 (file)
@@ -152,6 +152,81 @@ return L.view.extend({
                }
        },
 
+       populateV3Settings: function(tab, s){
+               let g, go, o;
+
+               o = s.taboption(tab, form.SectionValue, '__v3__',
+                       form.GridSection, 'v3',
+                       null, _('Here you can configure SNMPv3 settings'));
+
+               g = o.subsection;
+               g.anonymous = true;
+               g.addremove = true;
+               g.nodescriptions = true;
+               g.modaltitle = 'SNMPv3';
+
+               go = g.option(form.Value, 'username',
+                       _('username'),
+                       _('Set username to access SNMP'));
+               go.rmempty = false;
+               go.optional = false;
+               go.modalonly = true;
+
+               go = g.option(form.Flag, 'allow_write',
+                       _('Allow write'));
+               go.rmempty = false;
+               go.default = '0';
+
+               go = g.option(form.ListValue, 'auth_type',
+                       _('SNMPv3 authentication type'));
+               go.value('', _('none'));
+               go.value('SHA', _('SHA'));
+               go.value('MD5', _('MD5'));
+               go.rmempty = true;
+               go.default = 'SHA';
+
+               // SNMPv3 auth pass
+               go = g.option(form.Value, 'auth_pass',
+                       _('SNMPv3 authentication passphrase'));
+               go.password = true;
+               go.rmempty = true;
+               go.modalonly = true;
+               go.optional = false;
+               go.depends({'auth_type': '', '!reverse': true});
+
+               // SNMPv3 privacy/encryption type
+               go = g.option(form.ListValue, 'privacy_type',
+                       _('SNMPv3 encryption type'));
+               go.value('', _('none'));
+               go.value('AES', _('AES'));
+               go.value('DES', _('DES'));
+               go.rmempty = true;
+               go.default = 'AES';
+
+               // SNMPv3 privacy/encryption pass
+               go = g.option(form.Value, 'privacy_pass',
+                       _('SNMPv3 encryption passphrase'));
+               go.password = true;
+               go.rmempty = true;
+               go.modalonly = true;
+               go.optional = false;
+               go.depends({'privacy_type': '', '!reverse': true});
+
+               go = g.option(form.ListValue, 'RestrictOID',
+                       _('OID-Restriction'));
+               go.value('no', _('No'));
+               go.value('yes', _('Yes'));
+               go.default = 'no';
+               go.optional = false;
+               go.rmempty = false;
+
+               this.oid = g.option(form.Value,
+                       'RestrictedOID',
+                       _('OID'));
+               this.oid.datatype = 'string';
+               this.oid.depends('RestrictOID', 'yes');
+       },
+
        render: function(data) {
                let m, s, o, g, go;
 
@@ -296,6 +371,9 @@ return L.view.extend({
                this.populateV1V2CSettings('access_HostIP',
                        _('Communities via IP-Address range'), 'HostIP', s);
 
+               s.tab('v3', _('SNMPv3'));
+               this.populateV3Settings('v3', s);
+
                return m.render();
        },